import moment from 'moment'
import { app, remote } from 'electron';
import path from 'path'
const APP = process.type === 'renderer' ? remote.app : app;
const APP_PATH = path.join(APP.getPath('documents'), '/chenghuangmiao')
const DEFAULT_SAVE_PATH = APP_PATH + '\\自动保存';
export default class AutoSaverConfig {
    public savePath: string = DEFAULT_SAVE_PATH;
    public enable: boolean = false;
    public saveOnExit: boolean = false;
    public intervals: number = 1;
    public intervalUnit: any = 'hours';
    public ms: number = 0;
    constructor(c: any | undefined) {
        if (c) {
            Object.assign(this, c);
        }
        this.setIntervalValue(this.intervals, this.intervalUnit);
    }
    public setIntervalValue(value: number, unit: any) {
        this.intervals = value;
        this.intervalUnit = unit;
        this.ms = moment.duration(value, unit).asMilliseconds();
    }
}